<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>徽章 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/badge/badge.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 徽章</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>🏷️ 徽章演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item">
                        <h3>基础徽章</h3>
                        <div id="basicBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>成功徽章</h3>
                        <div id="successBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>错误徽章</h3>
                        <div id="errorBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>警告徽章</h3>
                        <div id="warningBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>信息徽章</h3>
                        <div id="infoBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>点状徽章</h3>
                        <div id="dotBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>计数徽章</h3>
                        <div id="countBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>超限计数</h3>
                        <div id="maxCountBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>小尺寸</h3>
                        <div id="smallBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>中尺寸</h3>
                        <div id="mediumBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>大尺寸</h3>
                        <div id="largeBadge"></div>
                    </div>

                    <div class="demo-item">
                        <h3>左上位置</h3>
                        <div id="topLeftBadge"></div>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/badge/badge.css"&gt;
&lt;script src="components/badge/badge.js"&lt;/script&gt;

// 2. 创建容器
&lt;div id="badgeContainer"&lt;/div&gt;

// 3. 初始化徽章组件
const badge = new Badge({
    container: '#badgeContainer',
    content: 'NEW',
    type: 'success',
    size: 'medium',
    position: 'top-right'
});

// 4. 设置内容
badge.setContent('HOT');

// 5. 设置计数
badge.setCount(5);

// 6. 设置类型
badge.setType('error');</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/badge/badge.js"></script>
    <script>
        // 基础徽章
        new Badge({
            container: '#basicBadge',
            content: 'NEW'
        });

        // 成功徽章
        new Badge({
            container: '#successBadge',
            content: 'NEW',
            type: 'success'
        });

        // 错误徽章
        new Badge({
            container: '#errorBadge',
            content: 'ERROR',
            type: 'error'
        });

        // 警告徽章
        new Badge({
            container: '#warningBadge',
            content: 'WARN',
            type: 'warning'
        });

        // 信息徽章
        new Badge({
            container: '#infoBadge',
            content: 'INFO',
            type: 'info'
        });

        // 点状徽章
        new Badge({
            container: '#dotBadge',
            dot: true,
            type: 'success'
        });

        // 计数徽章
        new Badge({
            container: '#countBadge',
            count: 5
        });

        // 超限计数
        new Badge({
            container: '#maxCountBadge',
            count: 150,
            maxCount: 99
        });

        // 小尺寸
        new Badge({
            container: '#smallBadge',
            content: 'NEW',
            size: 'small'
        });

        // 中尺寸
        new Badge({
            container: '#mediumBadge',
            content: 'NEW',
            size: 'medium'
        });

        // 大尺寸
        new Badge({
            container: '#largeBadge',
            content: 'NEW',
            size: 'large'
        });

        // 左上位置
        new Badge({
            container: '#topLeftBadge',
            content: 'NEW',
            position: 'top-left'
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100px;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 14px;
            color: var(--text-primary);
            width: 100%;
            text-align: center;
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            }
        }
    </style>
</body>
</html>
